<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="com.printeverywhere.dto.MailServer"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<SCRIPT LANGUAGE="JavaScript">
<!--

<!-- Begin
function Check(chk)
{
if(document.myform.Check_ctr.checked==true){
for (i = 0; i < chk.length; i++)
chk[i].checked = true ;
}else{

for (i = 0; i < chk.length; i++)
chk[i].checked = false ;
}
}

// End -->
</script>

<s:form action="updateMessage" method="post" theme="simple" name="myform" >
<table width="100%">
	<tr>
		<td>
			<div class="blue-text16" style="margin: 0px 0px 0px 0px">
				<s:if test="show == null || show=='inbox' ">
					<s:text name="lable.MessagingSystem.Inbox" />
					<s:set name="maxDisplayLimit = privateMailOption.maximumInboxMessages" />
				</s:if>
				<s:if test="show == 'sent'">
					<s:text name="lable.frontmessaging.Sent" />
					<s:set name="maxDisplayLimit = privateMailOption.maximumSentBoxMessages" />
				</s:if>
				<s:if test="show == 'unread'"><s:text name="lable.MessagingSystem.unread" /></s:if>
				<s:if test="show == 'flagged'"><s:text name="lable.MessagingSystem.flagged" /></s:if>
			</div>
		</td>
	</tr>
	<tr>
		<td><div class="header-separator-bg" style="margin: 10px 5px 17px 0px"></div></td>
	</tr>
	<tr>
		<td>
			<s:actionerror cssClass="error-text" theme="simple"/>
			<s:actionmessage cssClass="common-text" theme="simple"/>
		</td>
	</tr>
	<s:if test="mailList.size>0">
	<tr>
		<td>
			<table>
				<tr>
					<td class="common-bold-text"><s:text name="lable.MessagingSystem.MyMessages" /></td>
					<td></td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td>
			<table>
				<tr>
					<td class="common-bold-text"><s:text name="lable.MessagingSystem.Displayonly" />:</td>
					<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
					<td class="common-bold-text"><s:text name="lable.MessagingSystem.Period" />:</td>
					<td>
						<s:select theme="simple" cssClass="Textfiled-border"
							name="changeListStatus" value="%{changeListStatus}"
							list="#{'0':'All', '1':'Last 24 hours' , '2':'Last 7 days', '3':'Last 2 weeks','4':'Last 31 days'}" onchange="myform.submit();"></s:select>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td>
			<s:set var="pageSize" value="pageSize" />
			<display:table name="mailList" pagesize="${pageSize}" length="${maxDisplayLimit}"  cellpadding="6" style="width: 100%;" cellspacing="1" requestURI="showMessagingSystem.htm" id="row" class="common-text" >
				<display:column title="#" headerClass="grid-header-bg grid-header-text" class="grid-bg common-text" autolink="true" sortable="true">
					<input type="checkbox" id="check_list" name="check_list" value="<%=((MailServer) row).getId()%>">
				</display:column>
				<display:column title="Flag" autolink="true" sortable="true" headerClass="grid-header-bg grid-header-text" class="grid-bg common-text">
					<% if(((MailServer) row).getFlag() == false){ %>
						<img src="images/iconFlagOff.gif" alt="Flag" />
					<% }else{ %>
						<img src="images/iconFlagOn.gif" alt="Flag" />
					<% } %>
				</display:column>
				<display:column title="From" autolink="true" sortable="true" headerClass="grid-header-bg grid-header-text" class="grid-bg common-text">
					<% if((((MailServer) row).getUserByFromId()) == null || (((MailServer) row).getUserByFromId()).equals("")){ %>
						Print Pack Paper
					<% }else{ %>
						<%= ((MailServer) row).getUserByFromId().getUserId() %>
					<% } %>
				</display:column>
				<display:column autolink="true" title="Subject" sortable="true" headerClass="grid-header-bg grid-header-text" class="grid-bg common-text">

					<s:url action="showMessage" var="displayMessage">
					<s:param name="messageId" value="%{#attr.row.id}"/>
					</s:url>
						<s:a href="%{displayMessage}" cssClass="navi-link">
							<% if(((MailServer) row).getIsRead() == false ){ %>
								<b><%= ((MailServer) row).getSubject() %></b>
							<% }else{ %>
								<%= ((MailServer) row).getSubject() %>
							<% } %>
						</s:a>
				</display:column>
				<display:column  property="createdOn" autolink="true" title="Received" sortable="true" headerClass="grid-header-bg grid-header-text" class="grid-bg common-text" />
				<display:column  property="expiresDate" autolink="true" title="Expires" sortable="true" headerClass="grid-header-bg grid-header-text" class="grid-bg common-text" />
				<display:column  autolink="true" title="Status" sortable="true" headerClass="grid-header-bg grid-header-text" class="grid-bg common-text" >
					<% if(((MailServer) row).getStatus() == 1 ){ %>

							<% }else if(((MailServer) row).getStatus() == 2){ %>
								<img src="images/iconRepliedMail.gif" alt="Flag" />
							<% }else if(((MailServer) row).getStatus() == 3){ %>
								<img src="images/iconForwardMail.gif" alt="Flag" />
							<% } %>
				</display:column>
			</display:table>
		</td>
	</tr>
	<tr>
		<td>
			<table>
				<tr>
					<td><input type="checkbox" name="Check_ctr" value="yes" onchange="Check(document.myform.check_list)" /></td>
					<td>
						<table border="0" cellspacing="0" cellpadding="0">
							<tr>
									<td class="btn-grey-left1"></td>
								<td class="btn-grey-middle1 ">
									<s:submit name="deleteMsg" value="%{getText('button.Delete')}" theme="simple"
										cssClass="submit-btn-common" onclick="return wantToDelete('Are You sure you want to delete message');" />
								</td>
								<td class="btn-grey-right1"></td>
							</tr>
						</table>
					</td>
					<td>
						<s:select theme="simple" cssClass="Textfiled-border"
							name="changeStatus" value=""
							list="#{'0':'-- Mark as --', '1':'Read' , '2':'Unread', '3':'Flagged','4':'Not Flagged'}"></s:select>
					</td>
					<td>
						<table border="0" cellspacing="0" cellpadding="0">
							<tr>
									<td class="btn-grey-left1"></td>
								<td class="btn-grey-middle1 ">
									<s:submit name="gobtn" value="%{getText('button.go')}" theme="simple"
										cssClass="submit-btn-common" />
								</td>
								<td class="btn-grey-right1"></td>
							</tr>
						</table>
					</td>
					<td>
						<table>
							<tr>

							</tr>
						</table>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td>
			<table>
				<tr>
					<td class="common-bold-text"><s:text name="lable.MessagingSystem.Legend" />:</td>
					<td><img alt="Legend" src="images/iconFlagOn.gif" /></td>
					<td class="common-bold-text"><s:text name="lable.MessagingSystem.Flagged" /></td>
					<td><img alt="Legend" src="images/iconRepliedMail.gif" /></td>
					<td class="common-bold-text"><s:text name="lable.MessagingSystem.Respondedto" /></td>
					<td><img alt="Legend" src="images/iconForwardMail.gif" /></td>
					<td class="common-bold-text"><s:text name="lable.MessagingSystem.Forwarded" /> </td>
					<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
					<td>Messages per page:</td>
					<td>
						<s:if test="pageSize==25"><s:property value="pageSize" /></s:if><s:else><s:a href="showMessagingSystem.htm?pageSize=25&show=%{parameter}&changeListStatus=%{changeListStatus}">25</s:a></s:else>
						<s:if test="pageSize==50"><s:property value="pageSize" /></s:if><s:else><s:a href="showMessagingSystem.htm?pageSize=50&show=%{parameter}&changeListStatus=%{changeListStatus}">50</s:a></s:else>
						<s:if test="pageSize==100"><s:property value="pageSize" /></s:if><s:else><s:a href="showMessagingSystem.htm?pageSize=100&show=%{parameter}&changeListStatus=%{changeListStatus}">100</s:a></s:else>
						<s:if test="pageSize==200"><s:property value="pageSize" /></s:if><s:else><s:a href="showMessagingSystem.htm?pageSize=200&show=%{parameter}&changeListStatus=%{changeListStatus}">200</s:a></s:else>
					</td>
				</tr>
			</table>
		</td>
	</tr>
	<tr>
		<td><s:text name="lable.MessagingSystem.parm1" /></td>
	</tr>
	</s:if>
	<s:else>
		<td class="common-bold-text"><s:text name="lable.MessagingSystem.parm2" /></td>
	</s:else>
</table>
<s:hidden name="pageSize" value="%{pageSize}" />
<s:hidden name="show" value="%{parameter}" />
</s:form>
